package model.drawPanel;

import java.util.ArrayList;

import model.drawPanel.entitys.Entity;
import model.drawPanel.entitys.ITextChanger;

public class DrawOrder_textChange extends DrawOrder{

	/**
	 * 
	 */
	private static final long serialVersionUID = 101250112L;
	private int textRowNum;
	private String pre;
	private String change;
	
	public DrawOrder_textChange(int id,int textRowNum,String pre,String change) {
		super(id);
		this.textRowNum = textRowNum;
		this.pre = pre;
		this.change = change;
	}
	@Override
	public void execute(ArrayList<Entity> entitylist){
		for(Entity en:entitylist){
			if(en.getId()==id){
				ITextChanger t = (ITextChanger) en;
				t.changeText(textRowNum, change);
				break;
			}
		}
		
	}
	@Override
	public void undo(ArrayList<Entity> entitylist){
		for(Entity en:entitylist){
			if(en.getId()==id){
				ITextChanger t = (ITextChanger) en;
				t.changeText(textRowNum, pre);
				break;
			}
		}
	}

}
